package com.xfcy.blog.dto;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xfcy.blog.common.constant.DateConstant;
import com.xfcy.blog.valid.AddGroup;
import com.xfcy.blog.valid.ListValue;
import com.xfcy.blog.valid.UpdateGroup;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 晓风残月Lx
 * @date 2023/5/21 13:32
 */
@Data
public class ArticleDTO {
    @Null(message = "id应该为空", groups = AddGroup.class)
    @NotNull(message = "id不能为空", groups = UpdateGroup.class)
    private Long id;

    @NotBlank(message = "标题不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String title;

    @NotBlank(message = "头像不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String avatar;

    @NotBlank(message = "简介不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String summary;

    @NotBlank(message = "文章内容不能空",groups = {AddGroup.class, UpdateGroup.class})
    private String content;

    @NotBlank(message = "文章内容不能空",groups = {AddGroup.class, UpdateGroup.class})
    private String contentMd;

    @ListValue(vals = {0, 1}, groups = {UpdateGroup.class,AddGroup.class})
    private Integer isOriginal;
    @ListValue(vals = {0, 1}, groups = {UpdateGroup.class,AddGroup.class})
    private Integer isPublish;
    @ListValue(vals = {0, 1}, groups = {UpdateGroup.class,AddGroup.class})
    private Integer isSecret;
    @ListValue(vals = {0, 1}, groups = {UpdateGroup.class,AddGroup.class})
    private Integer isStick;

    private String originalUrl;

    private String remark;

    private String keywords;

    @NotBlank(message = "分类不能为空", groups = {UpdateGroup.class,AddGroup.class})
    private String categoryName;

    @NotEmpty(message = "标签不能为空", groups = {UpdateGroup.class,AddGroup.class})
    private List<String> tags;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = DateConstant.FORMAT_STRING, timezone = DateConstant.GMT_TIMEZONE)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = DateConstant.FORMAT_STRING, timezone = DateConstant.GMT_TIMEZONE)
    private LocalDateTime updateTime;


}
